package com.xiaoma;

import com.demo.starter.model.User;
import com.xiaoma.factorybean.HelloWorldServiceImpl;
import com.xiaoma.factorybean.HelloWorldServiceInterface;
import com.xiaoma.factorybean.MyFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 *
 * @version 1.0.0
 *
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
		HibernateJpaAutoConfiguration.class})
//@EnableConfigurationProperties
//@Import(value = {MyImportSelector.class})
//@EntityScan("com.xiaoma")
@Import(value = User.class)//导入普通类并声明为bean
public class DemoApplication {

	@Bean
	public HelloWorldServiceInterface myFactoryBean(){
		MyFactoryBean myFactoryBean=new MyFactoryBean();
		HelloWorldServiceInterface helloWorldServiceInterface=new HelloWorldServiceImpl();
		myFactoryBean.setInterfaceName("com.xiaoma.factorybean.HelloWorldServiceInterface");
		myFactoryBean.setTarget(helloWorldServiceInterface);
		return (HelloWorldServiceInterface)myFactoryBean.getObject();
	}

	public static void main(String[] args) {
		ConfigurableApplicationContext applicationContext = SpringApplication.run(DemoApplication.class, args);
//		HelloWorldServiceInterface bean = applicationContext.getBean(HelloWorldServiceInterface.class);
//		bean.sayHello();

/*		User bean = applicationContext.getBean(User.class);
		IPeople bean1 = (IPeople)applicationContext.getBean(IPeople.class);
    bean1.test();*/

//		HelloWorldServiceInterface bean = applicationContext.getBean(HelloWorldServiceInterface.class);
//		bean.sayHello();

//		MyCore bean2 = applicationContext.getBean(MyCore.class);
//		bean2.study();

/*		Object test02 = applicationContext.getBean("test02");
		System.out.println(test02);*/
/*
		Maj bean1 = applicationContext.getBean(Maj.class);
		bean1.test();

		com.xiaoma.config.User bean3 = applicationContext.getBean(com.xiaoma.config.User.class);
		bean3.test();*/





	}

}
